<?php
namespace App\Repositories\Backend;

use App\Models\Copywriter;
use Illuminate\Support\Facades\Auth;

class CopywriterRepository extends CommonRepository
{
    public function __construct(Copywriter $copywriter)
    {
        parent::__construct($copywriter);
    }


    public function getLists($input)
    {
        $default_search = [
            'filter' => ['id', 'comment', 'type'],
            'sort'   => [
                'created_at' => 'desc',
            ],
        ];
        $search = $this->parseParams($default_search, $input);
        return $this->model->parseWheres($search)->paginate();
    }





    public function create($introduce, $values)
    {

        $result = $this->getDetail('1');
        if(!$result){
            $result1 = $this->model->create([
                'type'        => '1',
                'comment'        => $introduce,
            ]);

            $result2 = $this->model->create([
                'type'        => '2',
                'comment'        => $values,
            ]);
        }else{
            $result1 = $this->model->where('type', '1')->update([
                'comment'        => $introduce,
            ]);
            $result2 = $this->model->where('type', '2')->update([
                'comment'        => $values,
            ]);
        }

        return true;
    }


}
